<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <!-- 1、引入依赖 -->
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

  <div id="app"></div>

  <!-- 2、编写react代码 -->
  <script type="text/babel">

    class App extends React.Component {
      constructor(){
        super()
        this.state = {
          firstname: 'plum',
          lastname: 'zhang',
          flag: true
        }

      }

      getFullName(){
        const { firstname, lastname } = this.state
        return firstname + ' ' + lastname
      }

      // 所有组件必须实现render方法
      render() {
        const { firstname, lastname, flag } = this.state

        // 必须用return返回
        return (
          // {}语法  里面可以是表达式
          <div>
            {/* 1、运算符表达式*/}
           <h2>{ firstname + ' ' + lastname}</h2>
           <h2>{2 * 5}</h2>


            {/* 2、三元表达式*/}
           <h2>{flag ? 1 : 2}</h2>


            {/* 3、函数调用*/}
           <h2>{this.getFullName()}</h2>
          </div>
        )
      }
    }


    ReactDOM.render(<App/>, document.getElementById('app')) 
  </script>
</body>
</html>